<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <!-- <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row> -->
    <el-row :gutter="10">
      <el-col :xs="24"
              :md="16">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
        <el-row :gutter="10">
          <el-col :xs="24"
                  :md="12">
            <div class="chart-wrapper">
              <pie-chart />
            </div>
          </el-col>
          <el-col :xs="24"
                  :md="12">
            <div class="chart-wrapper">
              <rose-chart />
            </div>
          </el-col>
        </el-row>
      </el-col>
      <el-col :xs="24"
              :md="8">
        <el-row>
          <div class="chart-wrapper">
            <div class="wrapper">
              <div class="inner">
                <div class="chart1">
                  <liquid-fill-chart />
                </div>
                <div class="btm"></div>
              </div>
            </div>
          </div>
        </el-row>
        <div class="box-card">
          <box-card />
        </div>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import BoxCard from './components/BoxCard'
import LiquidFillChart from './components/LiquidFillChart'
import RoseChart from './components/RoseChart'
import dayjs from 'dayjs'
var customParseFormat = require('dayjs/plugin/customParseFormat')
var isoWeek = require('dayjs/plugin/isoWeek')
var relativeTime = require('dayjs/plugin/relativeTime')
require('dayjs/locale/zh-cn')

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    PieChart,
    BarChart,
    BoxCard,
    LiquidFillChart,
    RoseChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis
      // records: [
      //   {
      //     name: '用户1',
      //     behavior: '进入了库房',
      //     time: '1588965300000'
      //   },
      //   {
      //     name: '用户2',
      //     behavior: '进入了库房',
      //     time: '1588855000000'
      //   },
      //   {
      //     name: '用户3',
      //     behavior: '进入了库房',
      //     time: '1588714000000'
      //   },
      //   {
      //     name: '用户4',
      //     behavior: '进入了库房',
      //     time: '1588613000000'
      //   },
      //   // {
      //   //   name: '用户5',
      //   //   behavior: '进入了库房',
      //   //   time: '1588512000000'
      //   // }
      //   // {
      //   //   name: 'man6',
      //   //   behavior: '进入了库房',
      //   //   time: '1588747000000'
      //   // },
      //   // {
      //   //   name: 'man7',
      //   //   behavior: '进入了库房',
      //   //   time: '1588746000000'
      //   // }
      // ]
    }
  },
  mounted() {
    dayjs.locale('zh-cn')
    dayjs.extend(customParseFormat)
    dayjs.extend(isoWeek)
    dayjs.extend(relativeTime)
    console.log(
      dayjs('2020-01-09 14:08:50').toNow()
    )
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }
  // .chart {
  //   width: 60.7%;
  //   // display: inline;
  // }
  .event {
    width: 100%;
    // display: inline;
  }
  .text {
    font-size: 20px;
  }

  .item {
    margin-bottom: 70px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: '';
  }
  .clearfix:after {
    clear: both;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
.wrapper .inner {
  // position: relative;
  width: 100%;
  // height: calc(100vh-50px);
  // margin-bottom:15px;
  // border: 1px solid #eeeeee;
  background: url('~@/assets/echarts/liquidFill/bg.png') no-repeat;
  background-size: 100% 100%;
}
.chart1 {
  width: 100%;
  background: url('~@/assets/echarts/liquidFill/fill-border.gif') no-repeat
    center bottom;
  background-size: 46% 79%;
  // margin: 10px auto 0;
}
.btm {
  width: 60%;
  height: 20px;
  background: url('~@/assets/echarts/liquidFill/icon-bot.png') no-repeat;
  background-size: 100% 100%;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
